package com.blogs.web.shejimoshi.dali;

/**
 * @Author: xiaokai
 * @Description: 单例模式
 * @Date: 2019/8/13
 * @Version: 1.0
 */
public class PersonFactory {

    //首先构造方法私有化
    private PersonFactory() {
    }

    private static PersonFactory instance = new PersonFactory();

    //其次提供方法获取
    public static  PersonFactory getInstance() {
        if (instance == null){
            instance = new PersonFactory();
        }
        return instance;
    }

    //通过测试方法调用
    public static void main(String[] args) {
        PersonFactory.getInstance().toString();
    }

}
